﻿using Kanban.BLLContainer;
using Kanban.IBLL;
using Kanban.Model;
using KanbanApi.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;

namespace KanbanApi.Controllers
{
    public class WarehouseWarnController : BaseController
    {
        private readonly IWarehouseWarnService WarehouseWarnService = Container.Resolve<IWarehouseWarnService>();
        [HttpGet]
        [Route("api/WarehouseWarn/GetData")]
        public async Task<Table<object>> GetData(string search, int pageSize, int pageIndex)
        {
            var response = await WarehouseWarnService.GetModelsByPageAsync(search, pageSize, pageIndex);
            return new Table<object>(response.Item1, response.Item2);
        }

        [HttpGet]
        [Route("api/WarehouseWarn/GetModel")]
        public Task<WarehouseWarn> GetModel(int id)
        {
            return WarehouseWarnService.GetModelAsync(id);
        }

        [Route("api/WarehouseWarn/Remove")]
        public Task<bool> Remove(int id)
        {
            return WarehouseWarnService.DeleteAsync(id);
        }

        [HttpPost]
        [Route("api/WarehouseWarn/Save")]
        public Task<bool> Save(WarehouseWarnRequest request)
        {
            return WarehouseWarnService.Save(request.Model);
        }

        [HttpPost]
        [Route("api/WarehouseWarn/BatchAdd")]
        public Task<int> BatchAdd(WarehouseWarnRequest request)
        {
            return WarehouseWarnService.BatchAdd(request.List);
        }

        [HttpPost]
        [Route("api/WarehouseWarn/BatchDel")]
        public async Task<object> BatchDel(string ids)
        {
            var response = await WarehouseWarnService.BatchDel(ids);
            return new { Success = response };
        }
    }
}
